<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWithdrawsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('withdraws', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->comment('用户ID');
            $table->unsignedInteger('coin_id')->comment('币种ID');
            $table->string('hash')->nullable()->comment('区块链交易ID');
            $table->unsignedDecimal('number', 20, 8)->comment('提现数量');
            $table->unsignedDecimal('fee', 20, 8)->comment('提现手续费');
            $table->string('address')->comment('提现地址');
            $table->string('note')->nullable()->default(null)->comment('地址备注');
            $table->string('tag')->nullable()->default(null)->comment('地址标签');
            $table->unsignedTinyInteger('status')->nullable()->default(0)->comment('提现状态: 0:审核中 1:已到账 2:已撤销 3:审核通过未处理 4:处理中');
            $table->timestamp('created_at')->nullable()->useCurrent()->comment('提现时间');
            $table->timestamp('updated_at')->nullable()->useCurrent()->comment('到账时间');

            $table->unique(['coin_id', 'hash']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('withdraws');
    }
}
